#ifndef _HELIX_XML_SUITE_H_
#define _HELIX_XML_SUITE_H_

// MyTestSuite.h
#include <cxxtest/TestSuite.h>
//#include <stdio.h>
#include "../Helix/Log.h"
#include "../Helix/XML/XMLUtil.h"
#include "../Helix/Util/PointerCheck.h"

using namespace helix;

class XMLNodeTest : public CxxTest::TestSuite
{
public:
	XMLNode *root;
	XMLNode *child1;
	XMLNode *child2;
	XMLNode *child1a;
	XMLNode *child1b;
	XMLNode *child2a;

	void setUp()
	{
		printf("\n\nXMLNodeTest::");

		root=new XMLNode();
		child1=new XMLNode();
		child2=new XMLNode();
		child1a=new XMLNode();
		child1b=new XMLNode();
		child2a=new XMLNode();

		root->addChild(child1);
		root->addChild(child2);
		child1->addChild(child1a);
		child1->addChild(child1b);
		child2->addChild(child2a);
	}

	void tearDown()
	{
		PtrCheck::safeDelete(root,"root",true);
		PtrCheck::safeDelete(child1,"child 1",false);
		PtrCheck::safeDelete(child2,"child 2",false);
		PtrCheck::safeDelete(child1a,"child 1a",false);
		PtrCheck::safeDelete(child1b,"child 1b",false);
		PtrCheck::safeDelete(child2a,"child 2a",false);
	}
	void testAddNode( void )
	{
		printf("TestAddNode");
		TS_ASSERT_EQUALS(2,root->numChildren());
		TS_ASSERT_EQUALS(2,child1->numChildren());
		TS_ASSERT_EQUALS(1,child2->numChildren());
	}

	void testSetGetAttribute( void )
	{
		printf("TestSetGetAttribute");
		string att1="attrib1";
		string attV1="value1";
		string att2="attrib2";
		string attV2="value2";
		root->addAttribute(att1,attV1);
		root->addAttribute(att2,attV2);

		TS_ASSERT_EQUALS(attV1,root->getAttribute(att1));
		TS_ASSERT_EQUALS(attV2,root->getAttribute(att2));
		TS_ASSERT_EQUALS(2,root->numAttributes());

		TS_ASSERT_DIFFERS(root->getAttribute(0),root->getAttribute(1));
	}

	void testAttributeNotFound( void)
	{
		printf("TestAttributeNotFound");

		string test=root->getAttribute(0);

		TS_ASSERT_EQUALS(0,test.length());
	}


};

#endif